<?php
/**
 ***** 扶摇而上、抱守本真 ******
 * @author Dana
 * @Date 2021/6/30
 */

$db = new PDO('mysql:host=localhost;dbname=test','test','123456');
$st = $db->query("select symbol,planet from zodiac",PDO::FETCH_BOUND);
$st->bindColumn('symbol',$symbol);
$st->bindColumn('planet',$planet);

/*while($st->fetch()){
    print "$symbol goes with $planet.\r\n";
}*/
//die;
$firstRow = $st->fetch();
print "The first results are that {$firstRow['symbol']} goes whih {$firstRow['planet']}\r\n";


//foreach ($st->fetchAll(PDO::FETCH_COLUMN) as $row){
//    print "{$row['symbol']} goes with {$row['planet']} \r\n";
//}

$pairs = [
   'Mars' =>'water',
   'Moon'=>'water',
   'Sun'=>'fire'
];

$row = $db->prepare("select sign from zodiac where element LIKE :element and Planet LIKE :planet");
$row->bindParam(':element',$element);
$row->bindParam(':planet',$planet);

foreach ($pairs as $planet => $element){
    $row->execute();
    var_dump($row->fetch());
}


